﻿#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string.h>
#include <math.h>
#include <unordered_map>
using namespace std;

class Trie {
private:
    struct Node {
        Node* child[26]{};
        bool isEnd;
    }root;
public:
    /** Initialize your data structure here. */
    Trie()
    {}

    /** Inserts a word into the trie. */
    void insert(string word) {
        Node* node = &root;
        for (auto& ch : word)
        {
            if (node->child[ch - 'a'] == nullptr)
            {
                node->child[ch - 'a'] = new Node();
            }
            node = node->child[ch - 'a'];
        }
        node->isEnd = true;
    }

    /** Returns if the word is in the trie. */
    bool search(string word) {
        Node* node = &root;
        for (auto& ch : word)
        {
            if (node->child[ch - 'a'] == nullptr) return false;
            node = node->child[ch - 'a'];
        }
        return node->isEnd == true;
    }

    /** Returns if there is any word in the trie that starts with the given prefix. */
    bool startsWith(string prefix) {
        Node* node = &root;
        for (auto& ch : prefix)
        {
            if (node->child[ch - 'a'] == nullptr) return false;
            node = node->child[ch - 'a'];
        }
        return true;
    }
};


int main()
{
    return 0;
}
